home *** CD-ROM | disk | FTP | other *** search
- /* btree.h - data structures and constants for BTREE modue */
- #define EOIX (-2) /* return value for end-of-index */
- #define IX_FAIL (-1) /* return value for failed operation */
- #define IX_OK 0 /* return value for success */
-
- typedef long RECPOS ; /* file pos. of index block/data rec. */
- #define NULLREC (-1L) /* special value for RECPOS */
-
- #define MAXKEY 100 /* maximum length of a key */
-
- typedef struct /* entry format in index */
- { RECPOS rptr ; /* points to lower level */
- char key[MAXKEY] ; /* start of key value */
- /* actual data type unknown */
- } ENTRY ;
-
- #define IXB_SIZE 1024 /* no. bytes in a block ( on disk ) */
- /* IXB_SIZE = IXB_SIZE - sizeof(int)*2 - sizeof(long) */
- #define IXB_SPACE 1016 /* no. bytes of entry space in block */
-
- typedef struct /* index block format */
- { RECPOS brec ; /* index file location of block */
- /* or location of next free block */
- int bend ; /* first unused location in block */
- int lvl ; /* records level no. (-1 = free) */
- char entries[IXB_SPACE] ; /* space for entries */
- } BLOCK ;
-
- #define MAX_LEVELS 4 /* four index levels permitted */
-
- typedef struct /* disk file index descriptor */
- { int nl ; /* number of index levels */
- RECPOS rb ; /* location of root block in file */
- RECPOS ff ; /* location of first free block */
- ENTRY dume ; /* dummy entry */
- } IX_DISK ;
-
- typedef struct /* in-memory index descriptor */
- { int ixfile ; /* descriptor of open index file */
- struct
- { RECPOS cblock ; /* current block number */
- int coffset ; /* current offset within block */
- } pos[MAX_LEVELS] ;
- int (*pcomp) () ; /* address of compare function */
- int (*psize) () ; /* address of entry size */
- BLOCK cache[MAX_LEVELS] ; /* cache for current blocks */
- IX_DISK dx ; /* disk resident stuff */
- } IX_DESC ;
-
-
-